home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u303.dms / in.adf / Link_File_Creator.AMOS / Link_File_Creator.amosSourceCode
Encoding:
AMOS Source Code  |  1990-11-07  |  10.1 KB  |  386 lines

  1. '                     AMOS Ascii-Reader Link File Creator
  2. '
  3. '                               By P.J.Hickman 
  4. '
  5. '                     ï¿½ Copyright 1990 Mandarin Software 
  6. Default 
  7. Screen Close 0
  8. SET_UP_SCREENS
  9. 'Set up global variables 
  10. Dim OPTION$(7,1)
  11. For LOP=0 To 7
  12.    OPTION$(LOP,0)=""
  13.    OPTION$(LOP,1)=""
  14. Next LOP
  15. MENU_TITLE$=Space$(60)
  16. AMOUNT_OF_OPTIONS=0
  17. FILE_PRESENT=False
  18. OPTION_FILLED=False
  19. LINK_FILLED=False
  20. 'Global variables for alert box  
  21. Dim LINE$(5),BUTTON$(3)
  22. On Menu Proc MENU_1,MENU_2
  23. 'Main loop 
  24. Repeat 
  25.    On Menu On 
  26.    CHECK_MOUSE
  27.    POSITION=Param
  28.    If FILE_PRESENT
  29.       If POSITION=1
  30.          MENU_TITLE_INPUT
  31.       End If 
  32.       If POSITION>=2 and POSITION<=9 and AMOUNT_OF_OPTIONS>=POSITION-2
  33.          OPTION_INPUT[POSITION-2]
  34.       End If 
  35.    End If 
  36. Until False
  37. Procedure CHECK_MOUSE
  38.    Repeat 
  39.       On Menu On 
  40.       CLICK=Mouse Click
  41.       POS=Mouse Zone
  42.    Until CLICK and POS>0 and Mouse Key=1
  43. End Proc[POS]
  44. Procedure DISPLAY_MENU
  45.    Shared MENU_TITLE$,OPTION$(),AMOUNT_OF_OPTIONS
  46.    Cls 0,0,20 To 640,200
  47.    For LOP=0 To 15 Step 2
  48.       Print At(14,LOP+5);(LOP/2)+1;At(14,LOP+5);"[";At(16,LOP+5);"]  ";OPTION$(LOP/2,0)
  49.    Next LOP
  50. End Proc
  51. Procedure CREATE_LINK_FILE
  52.    Shared OPTION$(),MENU_TITLE$,AMOUNT_OF_OPTIONS,FILE_PRESENT,FILE$
  53.    Screen 2
  54.    Cls 0
  55.    Pen 1
  56.    FILE$=""
  57.    For LOP=0 To 7
  58.       OPTION$(LOP,0)=""
  59.       OPTION$(LOP,1)=""
  60.    Next LOP
  61.    MENU_TITLE$=""
  62.    AMOUNT_OF_OPTIONS=0
  63.    Centre At(,9)+"Please type the name of your new menu."
  64.    CUSTOM_INPUT[60,8,11,1,1,0,32,127,True]
  65.    MENU_TITLE$=Param$
  66.    Print At(,9);Space$(80);
  67.    DISPLAY_OPTION[0]
  68.    OPTION_TITLE_INPUT[0]
  69.    OPTION_LINK_INPUT[0]
  70.    Inc AMOUNT_OF_OPTIONS
  71.    DISPLAY_MENU
  72.    FILE_PRESENT=True
  73. End Proc
  74. Procedure LINK_FILE_SAVE[TYPE]
  75.    Shared AMOUNT_OF_OPTIONS,MENU_TITLE$,OPTION$(),FILE$
  76.    Shared LINE$(),BUTTON$()
  77.    On Error Goto FATEL_ERROR1
  78.    If(TYPE=1 and Asc(FILE$)=0) or TYPE=2
  79.       FILE$=Fsel$("*.Lnk","","Please choose a save name")
  80.    End If 
  81.    If AMOUNT_OF_OPTIONS<7 Then Dec AMOUNT_OF_OPTIONS
  82.    IDTAG$="AARLFBYPJH"
  83.    IDTAG2$="END OF FILE!"
  84.    Open Out 1,FILE$
  85.    Print #1,IDTAG$
  86.    Print #1,MENU_TITLE$
  87.    Print #1,Str$(AMOUNT_OF_OPTIONS)
  88.    For LOP=0 To AMOUNT_OF_OPTIONS
  89.       Print #1,OPTION$(LOP,0)
  90.       Print #1,OPTION$(LOP,1)
  91.    Next LOP
  92.    Print #1,IDTAG2$
  93.    RECOVER_1:
  94.    Close 
  95.    Pop Proc
  96.    FATEL_ERROR1:
  97.    If FILE$<>""
  98.       For LOP=1 To 5
  99.          Bell 
  100.          Wait 2
  101.       Next LOP
  102.       LINE$(0)="Woops, disc error!"
  103.       BUTTON$(0)="Never mind."
  104.       ALERT[21,7,0,1,1,1]
  105.    End If 
  106.    Resume RECOVER_1
  107. End Proc
  108. Procedure LINK_FILE_LOAD
  109.    Shared FILE_PRESENT,FILE$,AMOUNT_OF_OPTIONS,MENU_TITLE$,OPTION$()
  110.    Shared LINE$(),BUTTON$()
  111.    On Error Goto FATEL_ERROR2
  112.    Repeat 
  113.       FILE$=Fsel$("*.Lnk","","Please choose a file to load")
  114.    Until Exist(FILE$)
  115.    Open In 1,FILE$
  116.    Input #1,TAGID$
  117.    If TAGID$<>"AARLFBYPJH"
  118.       Bell 
  119.       Print "tag wrong:";TAGID$
  120.       Pop Proc
  121.    End If 
  122.    Input #1,MENU_TITLE$
  123.    Input #1,TEMP$
  124.    AMOUNT_OF_OPTIONS=Val(TEMP$)
  125.    For LOP=0 To AMOUNT_OF_OPTIONS
  126.       Input #1,OPTION$(LOP,0)
  127.       Input #1,OPTION$(LOP,1)
  128.    Next LOP
  129.    FILE_PRESENT=True
  130.    If AMOUNT_OF_OPTIONS<7 Then Inc AMOUNT_OF_OPTIONS
  131.    MENU_TITLE_PRINT
  132.    DISPLAY_MENU
  133.    RECOVER_2:
  134.    Close 
  135.    Pop Proc
  136.    FATEL_ERROR2:
  137.    If FILE$<>""
  138.       For LOP=1 To 5
  139.          Bell 
  140.          Wait 2
  141.       Next LOP
  142.       LINE$(0)="Woops, disc error!"
  143.       BUTTON$(0)="Never mind."
  144.       ALERT[21,7,0,1,1,1]
  145.    End If 
  146.    Resume RECOVER_2 : 
  147. End Proc
  148. Procedure DISPLAY_OPTION[NUM]
  149.    Shared OPTION$(),MENU_TITLE$
  150.    Cls 0
  151.    Print At(0,0);Space$(80);At(0,1);Space$(80);
  152.    Centre At(,1)+MENU_TITLE$
  153.    For LOP=1 To Len(MENU_TITLE$)+2
  154.       TEMP$=TEMP$+"~"
  155.    Next LOP
  156.    Centre At(,2)+TEMP$
  157.    Print At(0,5);Space$(80)
  158.    Centre At(,5)+Border$("MENU OPTION"+Str$(NUM+1),1)
  159.    Print At(2,9);" Option title: [ ";OPTION$(NUM,0);Space$(40-Len(OPTION$(NUM,0)));At(60,9);"]"
  160.    Print At(2,11);"Link filename: [ ";Left$(OPTION$(NUM,1),40);Space$(40-Min(40,Len(OPTION$(NUM,1))));At(60,11);"]"
  161. End Proc
  162. Procedure OPTION_INPUT[NUM]
  163.    Shared OPTION$(),MENU_TITLE$,AMOUNT_OF_OPTIONS,FILE_PRESENT
  164.    DISPLAY_OPTION[NUM]
  165.    Centre At(,20)+Border$("RETURN TO MAIN MENU",1)
  166.    Repeat 
  167.       CHECK_MOUSE
  168.       POSITION=Param
  169.       If POSITION=1 Then MENU_TITLE_INPUT
  170.       If POSITION=4 Then OPTION_TITLE_INPUT[NUM]
  171.       If POSITION=5 Then OPTION_LINK_INPUT[NUM]
  172.       If OPTION$(NUM,0)<>"" Then OPTION_FILLED=True
  173.       If OPTION$(NUM,1)<>"" Then LINK_FILLED=True
  174.    Until(OPTION_FILLED=True and LINK_FILLED=True and POSITION=10) or(OPTION_FILLED=False and LINK_FILLED=False and POSITION=10)
  175.    FILE_PRESENT=True
  176.    If AMOUNT_OF_OPTIONS<7 and OPTION_FILLED and LINK_FILLED and NUM>AMOUNT_OF_OPTIONS-1 Then Inc AMOUNT_OF_OPTIONS
  177.    DISPLAY_MENU
  178. End Proc
  179. Procedure MENU_TITLE_INPUT
  180.    Shared MENU_TITLE$
  181.    Print At(0,2);Space$(80);
  182.    CUSTOM_INPUT[60,10,1,1,1,0,32,127,True]
  183.    MENU_TITLE$=Param$
  184.    MENU_TITLE_PRINT
  185. End Proc
  186. Procedure MENU_TITLE_PRINT
  187.    Shared MENU_TITLE$
  188.    Centre At(,1)+MENU_TITLE$
  189.    For LOP=1 To Len(MENU_TITLE$)+2
  190.       TEMP$=TEMP$+"~"
  191.    Next LOP
  192.    Centre At(,2)+TEMP$
  193. End Proc
  194. Procedure OPTION_TITLE_INPUT[NUM]
  195.    Shared OPTION$()
  196.    CUSTOM_INPUT[40,19,9,1,1,0,32,127,False]
  197.    OPTION$(NUM,0)=Param$
  198. End Proc
  199. Procedure OPTION_LINK_INPUT[NUM]
  200.    Shared OPTION$()
  201.    Repeat 
  202.       Repeat 
  203.          OPTION$(NUM,1)=Fsel$("*.*","","Pick file to link")
  204.       Until OPTION$(NUM,1)<>""
  205.    Until Exist(OPTION$(NUM,1))
  206.    TEMP=Len(OPTION$(NUM,1))-4
  207.    OPTION$(NUM,1)=Right$(OPTION$(NUM,1),TEMP)
  208.    Print At(2,11);"Link filename: [ ";Left$(OPTION$(NUM,1),40);Space$(40-Min(40,Len(OPTION$(NUM,1))));At(60,11);"]"
  209. End Proc
  210. Procedure SET_UP_SCREENS
  211.    Screen Open 2,640,200,2,Hires
  212.    Colour 1,$CCC
  213.    Curs Off : Flash Off : Cls 0
  214.    Reserve Zone 15
  215.    Print At(0,1);Zone$(Space$(79),1)
  216.    For LOP=0 To 15
  217.       Print At(0,LOP+4);Zone$(Space$(79),(LOP/2)+2)
  218.    Next LOP
  219.    Print At(0,20);Zone$(Space$(79),10)
  220.    Centre At(,5)+"AMOS Link File Creator"
  221.    Centre At(,6)+"~~~~~~~~~~~~~~~~~~~~~~~~"
  222.    Centre At(,8)+"By P.J.Hickman"
  223.    Inverse On 
  224.    Centre At(,11)+"Click the right mouse button to display menu."
  225.    Inverse Off 
  226.    'Set up menu   
  227.    Menu$(1)=" AMOS "
  228.    Menu$(1,1)=" About "
  229.    Menu$(1,2)="-------" : Menu Inactive(1,2)
  230.    Menu$(1,3)=" Quit  "
  231.    Menu$(2)=" Edit "
  232.    Menu$(2,1)=" Create Link File "
  233.    Menu$(2,2)="------------------" : Menu Inactive(2,2)
  234.    Menu$(2,3)=" Load Link File   "
  235.    Menu$(2,4)="------------------" : Menu Inactive(2,4)
  236.    Menu$(2,5)=" Save Link File   "
  237.    Menu$(2,6)=" Save As.......   "
  238.    Menu$(2,7)="------------------" : Menu Inactive(2,7)
  239.    Menu$(2,8)=" Print Link File  "
  240.    Menu On 
  241.    Repeat : Until Mouse Click
  242. End Proc
  243. Procedure MENU_1
  244.    Shared POSITION,LINE$(),BUTTON$()
  245.    If Choice(2)=1
  246.       LINE$(0)="Link File Creator"
  247.       LINE$(1)="~~~~~~~~~~~~~~~~~"
  248.       LINE$(2)=""
  249.       LINE$(3)=" By P.J.Hickman"
  250.       BUTTON$(0)="Have Fun!!!!"
  251.       ALERT[23,9,0,1,1,4]
  252.    End If 
  253.    If Choice(2)=3
  254.       Default 
  255.       End 
  256.    End If 
  257.    On Menu On 
  258. End Proc
  259. Procedure MENU_2
  260.    Shared FILE_PRESENT,POSITION
  261.    If Choice(2)=1 Then CREATE_LINK_FILE
  262.    If Choice(2)=3 Then LINK_FILE_LOAD
  263.    If Choice(2)=5 Then LINK_FILE_SAVE[1]
  264.    If Choice(2)=6 Then LINK_FILE_SAVE[2]
  265.    If Choice(2)=8 and FILE_PRESENT Then LINK_FILE_PRINT
  266.    On Menu On 
  267. End Proc
  268. Procedure LINK_FILE_PRINT
  269.    Shared OPTION$(),MENU_TITLE$,AMOUNT_OF_OPTIONS
  270.    Shared LINE$(),BUTTON$()
  271.    On Error Goto FATEL_ERROR3
  272.    Menu Off 
  273.    Lprint MENU_TITLE$
  274.    For LOP=1 To Len(MENU_TITLE$)
  275.       Lprint "~";
  276.    Next LOP
  277.    Lprint : Lprint 
  278.    If AMOUNT_OF_OPTIONS<7 Then Dec AMOUNT_OF_OPTIONS
  279.    For LOP=0 To AMOUNT_OF_OPTIONS
  280.       Lprint "OPTION NUMBER:";LOP+1
  281.       Lprint "OPTION TITLE: ";OPTION$(LOP,0)
  282.       Lprint "LINKED FILE: ";OPTION$(LOP,1)
  283.       Lprint : Lprint : Lprint 
  284.    Next LOP
  285.    RECOVER_3:
  286.    If AMOUNT_OF_OPTIONS<7 Then Inc AMOUNT_OF_OPTIONS
  287.    Menu On 
  288.    Pop Proc
  289.    FATEL_ERROR3:
  290.    For LOP=1 To 5
  291.       Bell 
  292.       Wait 2
  293.    Next LOP
  294.    LINE$(0)="There is a Printer problem!"
  295.    BUTTON$(0)="Sorry about that"
  296.    ALERT[32,7,0,1,1,1]
  297.    Resume RECOVER_3
  298. End Proc
  299. Procedure CUSTOM_INPUT[INPSIZE,X,Y,TCOL,CURSCOL,PAPCOL,SKEY,EKEY,RID]
  300.    Menu Off 
  301.    INP$=""
  302.    COUNT=0
  303.    SCANPRESS=0
  304.    X2=X
  305.    Paper PAPCOL
  306.    Print At(X,Y);Space$(INPSIZE+1);
  307.    Print At(X-2,Y);"[";At(X+INPSIZE+1,Y);"]"
  308.    Clear Key 
  309.    Repeat 
  310.       Locate X2,Y
  311.       Pen CURSCOL : Print "_" : Pen TCOL
  312.       Locate X2,Y
  313.       Repeat 
  314.          KEY_GET
  315.          PRESSKEY$=Param$
  316.          SCANPRESS=Scancode
  317.       Until(Asc(PRESSKEY$)>=SKEY and Asc(PRESSKEY$)<=EKEY) or SCANPRESS=65 or SCANPRESS=68
  318.       ' If SCANPRESS<>65 and COUNT>0 and SCANPRESS<>68 Then PRESSKEY$=Lower$(PRESSKEY$)
  319.       If SCANPRESS<>65 and COUNT<INPSIZE and SCANPRESS<>68
  320.          Print PRESSKEY$
  321.          INP$=INP$+PRESSKEY$
  322.          Inc COUNT
  323.          Inc X2
  324.       End If 
  325.       If SCANPRESS=65 and X2>X and SCANPRESS<>68
  326.          Dec COUNT
  327.          Dec X2
  328.          Locate X2,Y
  329.          Print "  ";
  330.          INP$=Left$(INP$,COUNT)
  331.       End If 
  332.    Until SCANPRESS=68 and COUNT>0
  333.    Print At(X2,Y);" "
  334.    Clear Key 
  335.    If RID
  336.       Print At(X-2,Y);Space$(INPSIZE+4);
  337.    End If 
  338.    Menu On 
  339. End Proc[INP$]
  340. Procedure KEY_GET
  341.    Repeat 
  342.       PRESSKEY$=Inkey$
  343.    Until PRESSKEY$<>""
  344. End Proc[PRESSKEY$]
  345. Procedure PAUSE[NUM]
  346.    For LOP=1 To NUM
  347.    Next 
  348. End Proc
  349. 'Aaron Fothergill's (slightly altered to work in hires) Alert Box
  350. '(Uses ZONE's 11+ and returns the button number as a PARAM)  
  351. Procedure ALERT[W,H,BACK_COL,LINE_COL,NB,NL]
  352.    Shared LINE$(),BUTTON$()
  353.    Menu Off 
  354.    TEMP=0
  355.    W=W*8
  356.    H=H*8
  357.    X=(Screen Width/2)-W/2
  358.    Y=10
  359.    Get Block 241,0,Y-2,Screen Width,H+6
  360.    Ink BACK_COL
  361.    Bar X,Y-2 To X+W,Y+H
  362.    Ink LINE_COL
  363.    Box X+1,Y-2 To X+W-1,Y+H-1
  364.    S=W/8/(NB+1)+1
  365.    Paper BACK_COL
  366.    Pen LINE_COL
  367.    For LOP=0 To NL
  368.       Locate 0,Y Text(Y)+1+LOP
  369.       Centre LINE$(LOP)
  370.    Next LOP
  371.    TEMP=0
  372.    While TEMP<>NB
  373.       Locate X Text(X)+S/2+S*TEMP,Y Text(Y+H)-2
  374.       Print Border$(Zone$(BUTTON$(TEMP),TEMP+11),2);
  375.       Inc TEMP
  376.    Wend 
  377.    TEMP=0
  378.    Repeat 
  379.       Repeat : Until Mouse Click and Mouse Key=1
  380.       TEMP=Mouse Zone
  381.    Until TEMP=>10
  382.    Put Block 241,0,Y-2
  383.    Del Block 241
  384.    Add TEMP,-10
  385.    Menu On 
  386. End Proc[TEMP]